import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

public class Demo11 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("C:\\Download\\text.txt"))
        {
            //此时 scanner 就是从文件读取
            Scanner scanner = new Scanner(inputStream);
            // 就可以使用scanner读取后续的数据
            String s = scanner.next();
            System.out.println(s);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
